package com.train.system.enums.impl;

import cn.hutool.core.util.ArrayUtil;
import com.train.system.enums.Enums;

import java.math.BigDecimal;

/**
 * 车类型枚举
 */
public enum TrainTypeEnums implements Enums {

    G("G", "高铁", new BigDecimal("1.2")),
    D("D", "动车", new BigDecimal("1")),
    K("K", "特快", new BigDecimal("0.8"));

    private final String code;

    private final String message;

    private final BigDecimal priceRate;

    TrainTypeEnums(String code, String message, BigDecimal priceRate) {
        this.code = code;
        this.message = message;
        this.priceRate = priceRate;
    }

    public static TrainTypeEnums getByCode(String type) {
        return ArrayUtil.firstMatch(item -> item.getCode().equals(type), values());
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public BigDecimal getPriceRate() {
        return priceRate;
    }
}
